package com.beidu.lottery.call.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.beidu.lottery.call.constant.RabbitMQConstant.*;


@Configuration
public class RabbitMQConfig {

    @Bean
    public Queue lotterySubmitQueue() {
        return new Queue(LOTTERY_SUBMIT_QUEUE, true);
    }

    @Bean
    public FanoutExchange lotterySubmitExchange() {
        //三个参数分别是名字，重启后是否依然有效，长期未用时是否删除
        return new FanoutExchange(LOTTERY_SUBMIT_EXCHANGE, true, false);
    }

    @Bean
    public Binding bindinglotterySubmitDirect() {
        return BindingBuilder.bind(lotterySubmitQueue()).to(lotterySubmitExchange());
    }

}
